package com.cesgroup.zw.spring.boot.library.echarts.pie.many;

import com.cesgroup.zw.spring.boot.echarts.component.series.Pie;
import com.cesgroup.zw.spring.boot.echarts.enums.FontWeight;
import com.cesgroup.zw.spring.boot.echarts.enums.Position;
import com.cesgroup.zw.spring.boot.echarts.model.data.SankeyData;
import com.cesgroup.zw.spring.boot.echarts.model.series.LabelLine;
import com.cesgroup.zw.spring.boot.echarts.model.style.ItemStyle;
import com.cesgroup.zw.spring.boot.echarts.model.style.LabelStyle;

/**
 * @author ytj
 * @date 2019/7/10 9:45
 */
@SuppressWarnings("serial")
public class ManyPieSeries extends Pie {
    public ManyPieSeries(Integer index,String name,String value,Object color1,Object color2){
        this.setName(name);
        this.setType("pie");
        this.setClockwise(false);
        this.setRadius(new Integer[]{60,70});
        this.setItemStyle(new ItemStyle(){{
            this.setColor(color1);
            this.setShadowColor(color1);
            this.setShadowBlur(0);
        }});
        this.setLabel(new LabelStyle(){{
            this.setShow(false);
        }});
        this.setLabelLine(new LabelLine(){{
            this.setShow(false);
        }});
        this.setHoverAnimation(false);
        this.setCenter(new String[]{index*20+10+"%","50%"});
        this.setData(new SankeyData[]{
                new SankeyData(){{
                    this.setValue(value);
                    this.setLabel(new LabelStyle(){{
                        this.setFormatter("function(params){ return params.value+'%'; }");
                        this.setPosition(Position.center);
                        this.setShow(true);
                        this.setFontSize(20);
                        this.setFontWeight(FontWeight.bold);
                        this.setColor(color1);
                    }});
                }},
                new SankeyData(){{
                    this.setValue(100-Integer.parseInt(value));
                    this.setName("invisible");
                    this.setItemStyle(new ItemStyle(){{
                        this.setColor(color2);
                    }});
                }}
        });
    }
}
